/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;

import java.awt.Component;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

/**
 *
 * @author David Ponce
 */
public class Renderer extends DefaultTreeCellRenderer{
    @Override
	public Component getTreeCellRendererComponent( JTree tree, Object value,
			boolean sel, boolean expanded, boolean leaf, int row,
			boolean hasFocus ) {

		super.getTreeCellRendererComponent( tree, value, sel, expanded,
				leaf, row, hasFocus );

		if( value instanceof DefaultMutableTreeNode ){
			DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
			Object user = node.getUserObject();
			if( user instanceof ToolTip ){
				setToolTipText( ((ToolTip)user).getTooltip() );
			}
			else
				setToolTipText( value.toString() );
		}
		else
			setToolTipText( value.toString() );

		return this;
	}
}